package com.ruoyi.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.domain.Rack;
import com.ruoyi.business.mapper.RackMapper;
import com.ruoyi.business.service.IRackService;
import com.ruoyi.common.utils.CommentUtil;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * 台架Service业务层处理
 * 
 * @author qiancheng
 * @date 2025-06-13
 */
@Service
public class RackServiceImpl extends ServiceImpl<RackMapper, Rack> implements IRackService
{
    @Autowired
    private RackMapper rackMapper;

    /**
     * 查询台架
     * 
     * @param id 台架主键
     * @return 台架
     */
    @Override
    public Rack selectRackById(Long id)
    {
        return rackMapper.selectRackById(id);
    }

    /**
     * 查询台架列表
     * 
     * @param rack 台架
     * @return 台架
     */
    @Override
    public List<Rack> selectRackList(Rack rack)
    {
        return rackMapper.selectRackList(rack);
    }

    /**
     * 新增台架
     * 
     * @param rack 台架
     * @return 结果
     */
    @Override
    public int insertRack(MultipartFile file, Rack rack) throws IOException {
        rack.setCreateTime(DateUtils.getNowDate());
        rack.setDraw(CommentUtil.upLoadFile(file));
        return rackMapper.insert(rack);
    }

    /**
     * 修改台架
     * 
     * @param rack 台架
     * @return 结果
     */
    @Override
    public int updateRack(Rack rack)
    {
        rack.setUpdateTime(DateUtils.getNowDate());
        return rackMapper.updateRack(rack);
    }

    /**
     * 批量删除台架
     * 
     * @param ids 需要删除的台架主键
     * @return 结果
     */
    @Override
    public int deleteRackByIds(Long[] ids)
    {
        return rackMapper.deleteRackByIds(ids);
    }

    /**
     * 删除台架信息
     * 
     * @param id 台架主键
     * @return 结果
     */
    @Override
    public int deleteRackById(Long id)
    {
        return rackMapper.deleteRackById(id);
    }
}
